﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ProductsList.aspx.cs" Inherits="admin_ProductsList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="js/themes/gray/easyui.css" />
    <link rel="stylesheet" type="text/css" href="js/themes/icon.css" />
    <script type="text/javascript" src="../js/jquery-1.4.1.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#Dt").datagrid({
                title: '产品列表',
                url: 'Operation.ashx?cmd=getProductsList',
                height: parent.document.body.clientHeight - 110,
                method: "GET",
                rownumbers: true,
                singleSelect: true,
                pagination: true,
                columns: [[
	                { title: 'ID', field: 'ID', width: 100, hidden: true },
                    { title: '名称', field: 'PNAME', width: 200 },
                    { title: '价格', field: 'PPRICE', width: 200 },
                    { title: '人气', field: 'PREDU', width: 200 },
                    { title: '类别', field: 'PTYPE', width: 200 },
                    { title: '日期', field: 'PDATE', width: 200 }
				]],
                onSelect: function (rowIndex, rowData) {
                    //parent.addTab("编辑新闻", "AddNew.aspx?id=" + rowData.ID, "icon-form");
                }
            });
            $('#from,#to').datebox({
                formatter: function (date) {
                    var y = date.getFullYear();
                    var m = date.getMonth() + 1;
                    var d = date.getDate();
                    return y + "-" + (m < 10 ? ("0" + m) : m) + "-" + (d < 10 ? ("0" + d) : d);
                }
            });
            $('#type').combobox({
                url: 'Operation.ashx?cmd=getProductsType',
                panelHeight: "auto",
                multiple: "true",
                valueField: 'val',
                textField: 'txt'
            });
        });
        function btn_add() {
            parent.addTab("发布产品", "AddProduct.aspx?id=-1", "icon-form");
        }
        function btn_edit() {
            var row = $('#Dt').datagrid('getSelected');
            if (row) {
                parent.addTab("编辑产品", "AddProduct.aspx?id=" + row.ID, "icon-form");
            }
            else {
                $.messager.alert("提示信息", "请选择一行", "info");
            }
        }
        function btn_remove() {
            var row = $('#Dt').datagrid('getSelected');
            if (row) {
                $.messager.confirm('提示信息', '你确定要删除所选定的数据吗?', function (r) {
                    if (r) {
                        var row = $('#Dt').datagrid('getSelected');
                        $.post("Operation.ashx?cmd=delProduct", { delId: row.ID }, function (data, status) {
                            var dd = eval("(" + data + ")")
                            if (dd.success) {
                                $("#Dt").datagrid("reload");
                            }
                            else {
                                $.messager.alert("提示信息", dd.msg, 'error');
                            }
                        }, "text");
                    }
                });
            } else {
                $.messager.alert("提示信息", "请选择一行", "info");
            }
        }
        function btn_search() {
            $("#Dt").datagrid({ queryParams: { name: $("#name").val(), type: $("input[name=type]").val(), from: $("input[name=from]").val(), to: $("input[name=to]").val()} });
        }
    </script>
</head>
<body>
    <table id="Dt" class="easyui-datagrid" toolbar="#dlg-toolbar">
    </table>
    <div id="dlg-toolbar" style="padding: 5px">
        <a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="btn_add()">
            添加</a> <a href="#" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="btn_edit()">
                修改</a><a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="btn_remove()">删除</a>
        名称：<input class="txt" id="name" />&nbsp;&nbsp;类别：<input class="txt" id="type" name="type" />&nbsp;&nbsp;日期：<input
            class="txt" id="from" name="from" editable="false" />-<input class="txt" id="to"
                name="to" editable="false" />
        <a href="#" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="btn_search()">
            查询</a>
    </div>
</body>
</html>
